package com.projectfixit.entity;

import java.io.Serializable;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;

import javax.persistence.Id;

public class AuthDO implements Serializable {
	@Id
	private String email;
	private byte[] password;
	private Properties configuration;

	private AuthDO() {
	}

	public AuthDO(String email, String password) throws NoSuchAlgorithmException {
		this.email = email;
		MessageDigest messageDigest = MessageDigest.getInstance("MD5");
		this.password = messageDigest.digest(password.getBytes());
	}

	public boolean isEquals(byte[] x) {
		for (int i = 0; i < password.length; i++) {
			if (x[i] != password[i]) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) throws NoSuchAlgorithmException {
		AuthDO ado = new AuthDO("kshah@mail.esignal.com", "kkk");
		MessageDigest messageDigest = MessageDigest.getInstance("MD5");
		byte[] x = messageDigest.digest("kkk".getBytes());
		System.out.println(ado.isEquals(x));
	}

}
